﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

class CControlMouse
{
    MouseState prevMouseState;
    //Game1 game;
    CMenu menu;
    MouseState currMouseState;
    int m_SelectButton = 0;
    bool b_NamTrong = false;

    public int selectButton(int m_SelectButton, Texture2D t_newgame1)
    {
        b_NamTrong = false;



        this.m_SelectButton = m_SelectButton;
        if ((currMouseState.X > 378) & (currMouseState.X < 378 + t_newgame1.Width))
            if (currMouseState.Y > 300)
            {
                if (currMouseState.Y < 300 + t_newgame1.Height)
                {
                    m_SelectButton = 0;
                    b_NamTrong = true;
                }
                else if (currMouseState.Y < 300 + t_newgame1.Height * 2)
                {
                    m_SelectButton = 1;
                    b_NamTrong = true;
                }
                else if (currMouseState.Y < 300 + (t_newgame1.Height) * 3)
                {
                    m_SelectButton = 2;
                    b_NamTrong = true;
                }
                else if (currMouseState.Y < 300 + (t_newgame1.Height) * 4)
                {
                    m_SelectButton = 3;
                    b_NamTrong = true;
                }
                else if (currMouseState.Y < 300 + (t_newgame1.Height) * 5)
                {
                    m_SelectButton = 4;
                    b_NamTrong = true;
                }
                else if (currMouseState.Y < 300 + (t_newgame1.Height) * 6)
                {
                    m_SelectButton = 5;
                    b_NamTrong = true;
                }

            }
        return m_SelectButton;
    }
    public bool DiChuot()
    {
        bool CoDi = false;
        prevMouseState = currMouseState;
        currMouseState = Mouse.GetState();

        if (prevMouseState != currMouseState)
            CoDi = true;
        return CoDi;
    }

    public bool Check(bool b_TrangThai)
    {
        if (b_NamTrong == true) //& (DiChuot() == true))
            b_TrangThai = false;
        return b_TrangThai;
    }

    public void Update(Game game)
    {
        currMouseState = Mouse.GetState();
        if ((m_SelectButton == 5) & (currMouseState.LeftButton == ButtonState.Pressed))
        { game.Exit(); }
        if ((m_SelectButton == 0) & (currMouseState.LeftButton == ButtonState.Pressed))
        { CManager.Show = 1; }
    }

    public void ShowMouse(SpriteBatch sb, Texture2D t_control_mouse)
    {
        sb.Draw(t_control_mouse, new Vector2(currMouseState.X, currMouseState.Y), Color.White);
    }

    public void Draw(SpriteBatch sb, Texture2D t_khung, Texture2D t_newgame1, int m_SelectButton)
    {
        //if(currMouseState != prevMouseState)
        //if ((currMouseState.X > 378 ) & (currMouseState.X < 378 + t_newgame1.Width))
        //if(m_SelectButton >= 0)
        sb.Draw(t_khung, new Vector2(380, 300 + m_SelectButton * (t_newgame1.Height - 5)), Color.White);
        //prevMouseState = currMouseState;
    }
}

